
clear

cd "C:\code"

import delimited datasetdiff.txt, delimiters(tab) clear

*label variables
label variable deaths_per_capita "Deaths Per Capita"
label variable deaths7_lgrowth "Weekly Fatality Growth Rate"
*label variable weekly_incr_deaths_per_capita "Weekly Change in Deaths Per Capita"
label variable stayhome "Stay at Home"
label variable emergency "State of Emergency"
label variable nursingmustaccept "Nursing Home Must Accept Positives"
label variable novisit "No Nursing Home Visits"
*label variable schoolshut "Schools Closed"
label variable employeemask "Employees Must Wear Masks"
label variable maskrec "Masks Recommended in Public"
label variable maskmandatory "Mandatory Masks in Public"
label variable parksclosed "Beaches and Parks Closed"
label variable openreverse "Business Re-openings Reversed"
label variable noelective "No Elective Procedures"
label variable restclosed "Restaurants Closed"
label variable barsclosed "Bars Closed"
label variable gymsclosed "Gyms Closed"
label variable spasclosed "Spas Closed"
label variable gathermax10 "Gatherings Limited to 10"
label variable gathermax100 "No Gatherings Over 100"
label variable gathermax100plus "No Gatherings and Limit>100"
label variable medriskclose "Medium Risk Business Closed"
label variable highriskclose "High Risk Business Closed"
label variable higherriskclose "Higher Risk Business Closed"
label variable highestriskclose "Highest Risk Businesses Closed"
label variable nursetotpop "Nursing Home Population"
label variable percapincome "Per capital Income"
label variable popdensity "Population Density"
label variable obese "Obesity"
label variable smoke "Smokers"
label variable housingdensity "Housing Density"
label variable t_first "Days since First Covid Case"
label variable deaths7_growth "Growth{\sub t+1}"
label variable deaths14_growth "Growth{\sub t+2}"
label variable deaths21_growth "Growth{\sub t+3}"
label variable deaths28_growth "Growth{\sub t+4}"
label variable deaths35_growth "Growth{\sub t+5}"
label variable deaths42_growth "Growth{\sub t+6}"
label variable deaths14_lgrowth "Growth{\sub t-2}"
label variable deaths21_lgrowth "Growth{\sub t-3}"
label variable deaths28_lgrowth "Growth{\sub t-4}"
label variable deaths35_lgrowth "Growth{\sub t-5}"
label variable deaths42_lgrowth "Growth{\sub t-6}"
label variable deaths7_per_cap_lag "Deaths per Capita{\sub t-1}"
label variable deaths14_per_cap_lag "Deaths per Capita{\sub t-2}"
label variable deaths21_per_cap_lag "Deaths per Capita{\sub t-3}"
label variable deaths28_per_cap_lag "Deaths per Capita{\sub t-4}"
label variable deaths35_per_cap_lag "Deaths per Capita{\sub t-5}"
label variable deaths42_per_cap_lag "Deaths per Capita{\sub t-6}"
label variable age65plus "Age 65+"
label variable age85plus "Age 85+"
label variable asian "Asian"
label variable black "Black"
label variable hispanic "Hispanic"
label variable nativeamer "Native Americans"
label variable other "Other"
label variable hothumidweekdays "Hot Humid Weekdays"
label variable nursetotpop "Nursing Home Pop."
label variable hothumidweekend "Hot Humid Weekend"
label variable coldweekday "Cold Weekdays"
label variable coldweekend "Cold Weekend"
label variable avgtemp "Average Temperature"

gen date1 = date(date, "DM20Y") 
format date1 %td
drop if date1 > mdy(12,31,2020)
drop if date1 < mdy(3,1,2020)

replace percapincome = percapincome/1000

drop if missing(deaths42_lgrowth)

*table 2 summary statistics

estpost tabstat deaths_per_capita deaths7_lgrowth nursetotpop age65plus age85plus asian black hispanic nativeamer other percapincome popdensity diabetes obese smoke housingdensity t_first hothumidweekdays hothumidweekend coldweekday coldweekend avgtemp, stat(mean p25 p50 p75 n sd) col(stat)
 
esttab . using "C:\code\output\table2_b.csv", replace label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs

estpost tabstat wks_stayhome if stayhome == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs


estpost tabstat wks_emergency if emergency == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs


estpost tabstat wks_nursingmustaccept if nursingmustaccept == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs


estpost tabstat wks_novisit if novisit == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs


estpost tabstat wks_employeemask if employeemask == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs

estpost tabstat wks_maskrec if maskrec == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs

estpost tabstat wks_maskmandatory if maskmandatory == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs

estpost tabstat wks_parksclosed if parksclosed == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs

estpost tabstat wks_openreverse if openreverse == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs

estpost tabstat wks_noelective if noelective == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs

estpost tabstat wks_restclosed if restclosed == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs

estpost tabstat wks_barsclosed if barsclosed == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs

estpost tabstat wks_gymsclosed if gymsclosed == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs

estpost tabstat wks_spasclosed if spasclosed == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs

estpost tabstat wks_gathermax10 if gathermax10 == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs

estpost tabstat wks_gathermax100 if gathermax100 == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs

estpost tabstat wks_gathermax100plus if gathermax100plus == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs

estpost tabstat wks_medriskclose if medriskclose == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs

estpost tabstat wks_highriskclose if highriskclose == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs

estpost tabstat wks_higherriskclose if higherriskclose == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs

estpost tabstat wks_highestriskclose if highestriskclose == 1, stat(mean p25 p50 p75 n sd) col(stat)

esttab . using "C:\code\output\table2_b.csv", append label cells("mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) count(fmt(0)) sd(fmt(3))") noobs
